Kernel: SageMath 10.4
# 1 # Portion of the circle x^2 + y^2 = 4 with x ≤ √2 # Let x== -2, the coordinate will look like (-2,0) # Let x== √2, this coordinate will look like (√2,√2) or (√2,-√2) t1 = var('t1') circle1 = parametric_plot((2*cos(t1), 2*sin(t1)), (t1, pi/4, pi), color='blue') circle2 = parametric_plot((2*cos(t1), 2*sin(t1)), (t1, pi, 7*pi/4), color='blue') # Line segments t=var('t') line1 = parametric_plot((t, t), (t, 0, sqrt(2)), color='green') line2 = parametric_plot((t, -t), (t, 0, sqrt(2)), color='green') # Small circle centered at (0.5, 1.2) small_circle = parametric_plot((0.1*cos(t) + 0.5, 0.1*sin(t) + 1.2), (t, 0, 2*pi), color='red') P=(circle1 + circle2 + line1 + line2 + small_circle) P
Image in a Jupyter notebook
#2 # 1. Rotate by 90 degrees counter-clockwise R = matrix([[0, -1], [1, 0]]) circle1_rotated = parametric_plot(R * vector((2*cos(t), 2*sin(t))), (t, pi/4, pi), color='blue') circle2_rotated = parametric_plot(R * vector((2*cos(t), 2*sin(t))), (t, pi, 7*pi/4), color='blue') line1_rotated = parametric_plot(R * vector((t, t)), (t, 0, sqrt(2)), color='green') line2_rotated = parametric_plot(R * vector((t, -t)), (t, 0, sqrt(2)), color='green') small_circle_rotated = parametric_plot(R * vector((0.1*cos(t) + 0.5, 0.1*sin(t) + 1.2)), (t, 0, 2*pi), color='red') P_rotated = circle1_rotated + circle2_rotated + line1_rotated + line2_rotated + small_circle_rotated show(P_rotated) # 2. Stretch horizontally and compress vertically by a factor of 2 S = matrix([[2, 0], [0, 1/2]]) circle1_stretched = parametric_plot(S * vector((2*cos(t), 2*sin(t))), (t, pi/4, pi), color='blue') circle2_stretched = parametric_plot(S * vector((2*cos(t), 2*sin(t))), (t, pi, 7*pi/4), color='blue') line1_stretched = parametric_plot(S * vector((t, t)), (t, 0, sqrt(2)), color='green') line2_stretched = parametric_plot(S * vector((t, -t)), (t, 0, sqrt(2)), color='green') small_circle_stretched = parametric_plot(S * vector((0.1*cos(t) + 0.5, 0.1*sin(t) + 1.2)), (t, 0, 2*pi), color='red') P_stretched = circle1_stretched + circle2_stretched + line1_stretched + line2_stretched + small_circle_stretched show(P_stretched) # 3. Reflect through line y = -x M = matrix([[0, -1], [-1, 0]]) circle1_reflected = parametric_plot(M * vector((2*cos(t), 2*sin(t))), (t, pi/4, pi), color='blue') circle2_reflected = parametric_plot(M * vector((2*cos(t), 2*sin(t))), (t, pi, 7*pi/4), color='blue') line1_reflected = parametric_plot(M * vector((t, t)), (t, 0, sqrt(2)), color='green') line2_reflected = parametric_plot(M * vector((t, -t)), (t, 0, sqrt(2)), color='green') small_circle_reflected = parametric_plot(M * vector((0.1*cos(t) + 0.5, 0.1*sin(t) + 1.2)), (t, 0, 2*pi), color='red') P_reflected = circle1_reflected + circle2_reflected + line1_reflected + line2_reflected + small_circle_reflected show(P_reflected) # 4. Project onto the line y = -2x P_matrix = matrix([[1/5, -2/5], [-2/5, 4/5]]) circle1_projected = parametric_plot(P_matrix * vector((2*cos(t), 2*sin(t))), (t, pi/4, pi), color='blue') circle2_projected = parametric_plot(P_matrix * vector((2*cos(t), 2*sin(t))), (t, pi, 7*pi/4), color='blue') line1_projected = parametric_plot(P_matrix * vector((t, t)), (t, 0, sqrt(2)), color='green') line2_projected = parametric_plot(P_matrix * vector((t, -t)), (t, 0, sqrt(2)), color='green') small_circle_projected = parametric_plot(P_matrix * vector((0.1*cos(t) + 0.5, 0.1*sin(t) + 1.2)), (t, 0, 2*pi), color='red') P_projected = circle1_projected + circle2_projected + line1_projected + line2_projected + small_circle_projected show(P_projected)
Image in a Jupyter notebookImage in a Jupyter notebookImage in a Jupyter notebookImage in a Jupyter notebook
# 3 B = Matrix([[1, 2], [0, 1]]) theta = pi / 4 A = Matrix([[cos(theta), -sin(theta)], [sin(theta), cos(theta)]]) # Define the standard basis vectors e1 = vector([1, 0]) e2 = vector([0, 1]) # Apply the shearing transformation Te1=A*e1 Te2=A*e2 Te1 Te2 # Apply the rotation transformation on the sheared vectors STe1=B*Te1 STe2=B*Te2 STe1 STe2
(1/2*sqrt(2), 1/2*sqrt(2))
# Create a plot for the original and transformed vectors using lines (plot(e1,color='blue')+plot(e2,color='blue',aspect_ratio=1)+plot(Te1,color='red')+plot(Te2,color='red',aspect_ratio=1)+plot(B*A*e1,color='green')+plot(B*A*e2,color='green',aspect_ratio=1)+parametric_plot( (.5*cos(t),.5*sin(t)),(t,0,pi/3),color='black')+plot(x,(x,-1,1),linestyle='--'))
Image in a Jupyter notebook
# Calculate composite matrix S(T(x)) = S ◦ T composite_matrix = B * A # Compute products of standard matrices AB and BA AB = A * B BA = B * A composite_matrix, AB, BA
( [3/2*sqrt(2) 1/2*sqrt(2)] [1/2*sqrt(2) 1/2*sqrt(2)] [1/2*sqrt(2) 1/2*sqrt(2)], [1/2*sqrt(2) 3/2*sqrt(2)], [3/2*sqrt(2) 1/2*sqrt(2)] [1/2*sqrt(2) 1/2*sqrt(2)] )
# 4) # The two compositions involve different sequences of transformations, leading to different final results. Due to the differing effects of shearing and rotation p (S ◦ T)(x) is not equal to S(T(x)).
# 5 # Define the matrices A1 = Matrix([[1, 0], [0, 1], [0, 0]]) A2 = Matrix([[1, 2], [3, -1], [2, 0]]) A3 = Matrix([[1, 2], [-1, -2], [3, -3]]) # Set the range for x and y x_range = (-10, 10) y_range = (-10, 10) # Create the parametric plots for A1 x, y = var('x y') X1 = A1[0, 0]*x + A1[0, 1]*y Y1 = A1[1, 0]*x + A1[1, 1]*y Z1 = A1[2, 0]*x + A1[2, 1]*y plot_A1 = parametric_plot3d((X1, Y1, Z1), (x, x_range[0], x_range[1]), (y, y_range[0], y_range[1]),color="red") # Create the parametric plots for A2 X2 = A2[0, 0]*x + A2[0, 1]*y Y2 = A2[1, 0]*x + A2[1, 1]*y Z2 = A2[2, 0]*x + A2[2, 1]*y plot_A2 = parametric_plot3d((X2, Y2, Z2), (x, x_range[0], x_range[1]), (y, y_range[0], y_range[1]),color="green") # Create the parametric plots for A3 X3 = A3[0, 0]*x + A3[0, 1]*y Y3 = A3[1, 0]*x + A3[1, 1]*y Z3 = A3[2, 0]*x + A3[2, 1]*y plot_A3 = parametric_plot3d((X3, Y3, Z3), (x, x_range[0], x_range[1]), (y, y_range[0], y_range[1])) # Show the plots show(plot_A1 + plot_A2 + plot_A3)
# Define the parameters s, t = var('s t') # Define the parametric equations for the paraboloid X = s * cos(t) Y = s * sin(t) Z = s^2 # Create the 3D parametric plot for the paraboloid plot_G = parametric_plot3d((X, Y, Z), (s, 0, 2), (t, 0, 2*pi)) # Show the plot show(plot_G)
# Define the parameters s, t = var('s t') # Define the parametric equations for the paraboloid X = s * cos(t) Y = s * sin(t) Z = s^2 # Create the parametric plot for the paraboloid plot_G = parametric_plot3d((X, Y, Z), (s, 0, 2), (t, 0, 2*pi), color='lightgray') # Define the matrices A4 = Matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) A5 = Matrix([[1, 0, 1], [0, 1, 1], [1, 1, 0]]) A6 = Matrix([[-1, 0, 1], [0, 1, -1], [1, -1, 0]]) A7 = Matrix([[1, -1, 1], [2, -2, 2], [-1, 1, -1]]) # Create the transformed plots for A4 plot_A4 = parametric_plot3d( (A4[0, 0] * X + A4[0, 1] * Y + A4[0, 2] * Z, A4[1, 0] * X + A4[1, 1] * Y + A4[1, 2] * Z, A4[2, 0] * X + A4[2, 1] * Y + A4[2, 2] * Z), (s, 0, 2), (t, 0, 2 * pi), color='blue' ) # Create the transformed plots for A5 plot_A5 = parametric_plot3d( (A5[0, 0] * X + A5[0, 1] * Y + A5[0, 2] * Z, A5[1, 0] * X + A5[1, 1] * Y + A5[1, 2] * Z, A5[2, 0] * X + A5[2, 1] * Y + A5[2, 2] * Z), (s, 0, 2), (t, 0, 2 * pi), color='red') # Create the transformed plots for A6 plot_A6 = parametric_plot3d( (A6[0, 0] * X + A6[0, 1] * Y + A6[0, 2] * Z, A6[1, 0] * X + A6[1, 1] * Y + A6[1, 2] * Z, A6[2, 0] * X + A6[2, 1] * Y + A6[2, 2] * Z), (s, 0, 2), (t, 0, 2 * pi), color='green' ) # Create the transformed plots for A7 plot_A7 = parametric_plot3d( (A7[0, 0] * X + A7[0, 1] * Y + A7[0, 2] * Z, A7[1, 0] * X + A7[1, 1] * Y + A7[1, 2] * Z, A7[2, 0] * X + A7[2, 1] * Y + A7[2, 2] * Z), (s, 0, 2), (t, 0, 2 * pi), color='purple' ) # Show all plots together show(plot_G + plot_A4 + plot_A5 + plot_A6 + plot_A7)
# Define the standard basis vectors e1 = vector([1, 0, 0]) e2 = vector([0, 1, 0]) e3 = vector([0, 0, 1]) # Create a grid of points based on linear combinations of e1, e2, e3 grid_points = [] for x in range(-2, 2): for y in range(-2, 2): for z in range(-2, 2): grid_points.append(x * e1 + y * e2 + z * e3) # Create the parametric plot for the grid plot_H = point3d(grid_points, color='lightgray', size=30) # Define the matrices A4 = Matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) A5 = Matrix([[1, 0, 1], [0, 1, 1], [1, 1, 0]]) A6 = Matrix([[-1, 0, 1], [0, 1, -1], [1, -1, 0]]) A7 = Matrix([[1, -1, 1], [2, -2, 2], [-1, 1, -1]]) # Transform grid points for each matrix transformed_A4 = [A4 * p for p in grid_points] transformed_A5 = [A5 * p for p in grid_points] transformed_A6 = [A6 * p for p in grid_points] transformed_A7 = [A7 * p for p in grid_points] # Create the transformed plots plot_T_A4 = point3d(transformed_A4, color='blue', size=30) plot_T_A5 = point3d(transformed_A5, color='red', size=30) plot_T_A6 = point3d(transformed_A6, color='green', size=30) plot_T_A7 = point3d(transformed_A7, color='purple', size=30) # Show all plots together show(plot_H + plot_T_A4 + plot_T_A5 + plot_T_A6 + plot_T_A7)